package cn.dengyongsheng.mybatis_test.mappers;

import cn.dengyongsheng.mybatis_test.entities.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user")
    @Results(
            @Result(property = "dept", column = "deptid",
            one = @One(select = "cn.dengyongsheng.mybatis_test.mappers.DeptMapper.getDeptById"))
    )
    List<User> getAllUser();

    @Select("select * from user where userid=#{userid}")
    @Results(
            @Result(property = "dept", column = "deptid",
            one = @One(select = "cn.dengyongsheng.mybatis_test.mappers.DeptMapper.getDeptById"))
    )
    User getUserById(Integer userid);

    @Select("select * from user where deptid=#{deptid}")
    List<User> getUserListByDeptId(Integer deptid);
}
